package server.container;

import server.pojo.Request;
import server.pojo.Response;

import java.util.HashMap;
import java.util.Map;
import java.util.function.BiConsumer;

public class MyEngine implements BaseContainer {

    Map<String, MyHost> map = new HashMap<>();

    public MyEngine(MyService myService) {
        myService.add(this);
    }

    public void add(String key, MyHost myHost) {
        map.put(key, myHost);
    }

    public void invoke(Request request, Response response) {
        map.forEach(new BiConsumer<String, MyHost>() {
            @Override
            public void accept(String s, MyHost myHost) {
                myHost.invoke(request, response);
            }
        });
    }
}
